package com.shiro.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shiro.dao.UserBeanMapper;
import com.shiro.pojo.AuthorityBean;
import com.shiro.pojo.RoleBean;
import com.shiro.pojo.UserBean;
@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserBeanMapper userBeanMapper;
	
	public List<UserBean> findUserAll() {
		return userBeanMapper.selectUserAll();
	}

	public UserBean findUserById(Integer id) {
		return userBeanMapper.selectUserById(id);
	}

	public int addUser(UserBean user) {
		return 0;
	}

	public int deleteUser(Integer id) {
		return 0;
	}

	public int updateUser(UserBean user) {
		return 0;
	}

	public UserBean login(String username, String password) {
		return userBeanMapper.selectUserByUsernameAndPassword(username, password);
	}

	public UserBean findUserByUserName(String username) {
		return userBeanMapper.selectUserByName(username);
	}

	/**
	 * 通过用户名查询用户所拥有的角色
	 */
	public List<RoleBean> findRoleByUsername(String username) {
		return userBeanMapper.selectRoleByUsername(username);
	}

	/**
	 * 通过用户名查询用户所拥有的角色
	 */
	public List<AuthorityBean> findAuthorityByUsername(String username) {
		return userBeanMapper.selectAuthorityByUsername(username);
	}
	

}
